<!--
 * @Description: 
 * @Author: ldx
 * @Date: 2023-03-02 21:05:41
 * @LastEditors: ldx
 * @LastEditTime: 2023-03-02 21:44:45
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body{
      margin: 0;
      overflow: hidden;
    }
    #canvas{
      /* background: red; */
    }
  </style>
</head>
<body>
  <canvas id="canvas"></canvas>
  <script type="module">
    import {Color} from 'https://unpkg.com/three/build/three.module.js'
    const canvas = document.querySelector('#canvas')
    // 设置canvas容器的宽高
    canvas.width = window.innerWidth
    canvas.height = window.innerHeight
    // 获取webgl上下文
    const gl = canvas.getContext('webgl');
    const color = new Color('rgb(255,0,0)')
    // 声明将来用来清空绘图区的颜色。分别对应r,g,b,a
    gl.clearColor(color.r,color.g,color.b,1)
    // 使用之前声明的颜色，清空绘图区
    gl.clear(gl.COLOR_BUFFER_BIT)

    !(function ani(){
      color.offsetHSL(0.01,0,0)
      gl.clearColor(color.r,color.g,color.b,1)
      gl.clear(gl.COLOR_BUFFER_BIT)
      requestAnimationFrame(ani)
    })()
  </script>
</body>
</html>